home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / initvar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.7 KB  |  54 lines

  1. /*
  2. \funcref{initvar}{VAR\_ initvar (\params)}
  3.     {
  4.         {VAR\_} {v} {variable to initialize}
  5.     }
  6.     {initialized variable}
  7.     {xrealloc()}
  8.     {}
  9.     {initvar.c}
  10.     {
  11.         This function initializes the variable, passed as argument, if
  12.         necessary. Initialization may be necessary if the specified variable is
  13.         not of type {\em e\_int}.
  14.  
  15.         The initialization of a variable includes the following actions:
  16.  
  17.         \begin{itemize}
  18.  
  19.             \item Field {\em vu.i} is set to point to allocated memory of the
  20.             size of an {\em INTER\_} structure if this field is {\em NULL}.
  21.  
  22.             \item The {\em count} size within this structure, i.e., field {\em
  23.             vu.i$\rightarrow$count}, is set to {\bf one} if a new variable is
  24.             created. Note that if a variable is re-initialized, the {\em count}
  25.             field is {\bf not} increased: this may be an action required by the
  26.             caller. The count indicates that at least one user will use the
  27.             memory block attached to the variable.
  28.  
  29.             \item The pointer and the counter within this field are set to zero
  30.             by assigning the fields {\em vu.i$\rightarrow$ls.list.size} and
  31.             {\em vu.i$\rightarrow$ls.list.element} to zero and {\em NULL}
  32.             respectively if a new variable is created.
  33.  
  34.         \end{itemize}
  35.     }
  36. */
  37.  
  38. #include "icrssdef.h"
  39.  
  40. VAR_ initvar (v)
  41. VAR_ v;
  42. {
  43.     if ( (v.type & (e_str | e_list)) && ! v.vu.i )
  44.     {
  45.         v.vu.i = xrealloc (NULL, sizeof (INTER_));
  46.         v.vu.i->count = 1;
  47.         v.vu.i->ls.list.size = 0;
  48.         v.vu.i->ls.list.element = NULL;
  49.         v.vu.i->ls.str = NULL;
  50.     }
  51.  
  52.     return (v);
  53. }
  54.